pub mod student_course;
/**
 * 学生模块文件
 * 包含两个子模块 student_info 和 student_course
 */
pub mod student_info;

use crate::{Programmer, Work};

enum  Tools{
    Java,
    Python,
    Go,Rust
}
/**
 * 实现程序员的接口特质
 */
impl Work for Programmer {
    // 实现工作方法
    fn design(&self) {
        println!("程序员{}在工作", self.name);
    }
    fn code(&self) {
        println!("程序员{}在学习", self.name);
    }
    fn test(&self) {
        println!("程序员{}在测试", self.name);
    }
}

pub fn go() {
    println!("学生模块");
}

fn code_with_tools(tools: Option<Tools>) {
    tools.unwrap_or_else(|| {   
        println!("没有找到工具");
        Tools::Go
    });
}

#[derive(Debug)]
struct Rectangle {
    width: u32,
    height: u32,
}

fn sort_list(){
    let mut list = [
        Rectangle { width: 10, height: 1 },
        Rectangle { width: 3, height: 5 },
        Rectangle { width: 7, height: 12 },
    ];

    list.sort_by_key(|r| r.width);
    println!("{list:#?}");
}
#[test]
fn test_iter(){
    let v1 = vec![1, 2, 3];
    let mut v1_iter = v1.iter();
    assert_eq!(v1_iter.next(), Some(&1));
    assert_eq!(v1_iter.next(), Some(&2));
    assert_eq!(v1_iter.next(), Some(&3));
    assert_eq!(v1_iter.next(), None);

    let iter = v1.into_iter();
}